package cn.lanqiao.bigDate.mapper.sys;

import cn.lanqiao.bigDate.entity.sys.SysUserRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
 * @description 用户和角色关联表Mapper
 * @author yang
 * @date 2022-03-13
 */
@Mapper
public interface SysUserRoleMapper extends BaseMapper<SysUserRole> {

    @Select(
    "<script>select t0.* from sys_user_role t0 " +
    //add here if need left join
    "where 1=1" +
    "<when test='userId!=null and userId!=&apos;&apos; '> and t0.user_id=#{userId}</when> " +
    "<when test='roleId!=null and roleId!=&apos;&apos; '> and t0.role_id=#{roleId}</when> " +
    "<when test='id!=null and id!=&apos;&apos; '> and t0.id=#{id}</when> " +
    //add here if need page limit
    //" limit ${page},${limit} " +
    " </script>")
    List<SysUserRole> pageAll(SysUserRole queryParamDTO,int page,int limit);

    @Select("<script>select count(1) from sys_user_role t0 " +
    //add here if need left join
    "where 1=1" +
    "<when test='userId!=null and userId!=&apos;&apos; '> and t0.user_id=#{userId}</when> " +
    "<when test='roleId!=null and roleId!=&apos;&apos; '> and t0.role_id=#{roleId}</when> " +
    "<when test='id!=null and id!=&apos;&apos; '> and t0.id=#{id}</when> " +
     " </script>")
    int countAll(SysUserRole queryParamDTO);

}